'''
Author: Liu Zhi Biao
Date: 2023-02-17 09:54:03
LastEditors: Liu Zhi Biao
LastEditTime: 2023-02-17 15:48:57
FilePath: \Runoob_basic\runoob3.py
Description: 

Copyright (c) 2023 by ${git_name_email}, All Rights Reserved. 
'''

from collections import deque
import fun
import sys

class Runoob:
    def change(self, a):
        print(id(a))
        a = 10
        print(id(a))

    def changeme(self, mylist):
        mylist.append(666)
        print("函数内取值：", mylist)
        return
    
    def changeme_t(self):
        mylist = [10, 20, 30]
        self.changeme(mylist)
        print("函数外取值", mylist)

    def fun(self, p1, p2, p3 = 24):
        print(f"p1 = {p1}, p2 = {p2}, p3 = {p3}")

    def fun2(self, *p):
        print(p)

    def test_fun(self):
        # 必须参数 必需参数须以正确的顺序传入函数。调用时的数量必须和声明时的一样。
        self.fun(1,2,3)
        # 关键字参数
        self.fun(p2 = 1, p1 = 2, p3 = 3)
        # 默认参数
        self.fun(1,2)
        # 不定长参数
        self.fun2(1)
        self.fun2(1,2)
        self.fun2(1,2,3)
        # 匿名函数
        sum = lambda a, b: a + b
        print(sum(1,2))
        # return 语句 略

    def data_struct(self):
        # 列表
        a = [12, 42, 32, 66, 66, 2, 7]
        print(a.count(66), a.count(60))
        a.insert(1, 77)
        a.append(90)
        print(a)
        print(a.index(2))
        a.remove(2)
        print(a)
        # 列表当栈
        stack = [1,2,3]
        print(stack.append(4))
        print(stack.pop())
        print(stack.pop())
        print(stack.pop())
        # 列表当队列
        queue = deque([1,2,3])
        print(queue.popleft())
        print(queue.popleft())
        # 列表推导式
        # 嵌套列表

    def myset(self):
        basket = {1, 2, 2, 3, 4}
        print(basket)
        # 集合是不重复的元素集
        print( 1 in basket)
        print( 5 in basket)
        a = set('abracadabra')
        b = set('alacazam')
        print(a)
        print(b)
        print(a - b)
        print(a | b)
        print(a & b)
        print(a ^ b)

    def zidian(self):
        tel = {'jack': 4096, 'zhi': 5566}
        tel['bige'] = 9090
        print(tel)
        del tel['jack']
        print(tel)
        bili = dict([('sape', 4139), ('guido', 4127), ('jack', 409)])
        print(bili)
        for k, v in bili.items():
            print(k, v, end=' ')
        question = ['name', 'age', 'heigit']
        answer = ['lzb', 27, 170]
        for q, a in zip(question, answer):
            print("{0}:{1}".format(q,a))



    def __init__(self):
        # self.change(12)
        # self.changeme_t()
        # self.test_fun()
        # self.data_struct()
        # self.myset()
        # self.zidian()
        fun.sum(1,2)

# print("8778787")

if __name__ =="__main__":
    # print("123456789")l
    print(dir(sys))
    run = Runoob()